﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

namespace Jackie.Silverliight.SetpBySetp.Html
{
    public partial class CreateElement : Page
    {
        public CreateElement()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private int i = 1;
        private void createButton_Click(object sender, RoutedEventArgs e)
        {
            HtmlElement parent = HtmlPage.Document.GetElementById("list");

            HtmlElement child = HtmlPage.Document.CreateElement("li");
            child.SetAttribute("id", "li" + i.ToString());
            child.SetAttribute("innerText", this.input.Text);

            parent.AppendChild(child);
            i++;
        }

        private void removeButton_Click(object sender, RoutedEventArgs e)
        {
            HtmlElement parent = HtmlPage.Document.GetElementById("list");

            HtmlElement child = HtmlPage.Document.GetElementById(this.inputId.Text);

            parent.RemoveChild(child);
        }

    }
}
